import web
import linecache
import time
from pymongo import MongoClient
from random import randint

        
urls = (
    '/n15s', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self):
        data=''
        conn = MongoClient('127.0.0.1', 27017)
        db=conn.studyurl
        dbset=db.mp4url
        rint=randint(1,int(dbset.find_one({'url':'numcount'})['num']))
        data=dbset.find_one({'num':str(rint)})['url']
        conn.close()
        time.sleep(1)
        web.header('Access-Control-Allow-Origin', '*') 
        return data


if __name__ == "__main__":
    app.run()